package apiday03.collection;


import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortPoint {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(27, 56));
        list.add(new Point(45, 12));
        list.add(new Point(72, 10));
        list.add(new Point(22, 75));
        list.add(new Point(52, 82));
        System.out.println("原始数据：   " + list);
        Collections.sort(list, (o1, o2) -> o1.getX() - o2.getX());

//        Collections.sort(list, new Comparator<Point>() {
//            @Override
//            public int compare(Point o1, Point o2) {//前减后为升，后减前为降
//                return o1.getX()- o2.getX();//按x大小升序
//            }
//        });
        System.out.println("排序后数据：  " + list);


    }
}
